package com.ciaojian.client.controller;


import com.ciaojian.client.service.CouponPackageServiceImpl;
import com.ciaojian.core.model.CouponPackage;
import com.ciaojian.core.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 劵包表 前端控制器
 * </p>
 *
 * @author Atlakyn
 * @since 2021-03-03
 */
@Api(tags = "券包")
@RestController
@RequestMapping("/coupon-packages")
public class CouponPackageController {
    @Resource
    private CouponPackageServiceImpl couponPackageService;

    @ApiOperation("获取全部券包")
    @GetMapping
    public Result getCouponPackageList(@RequestParam(value = "displayMall", defaultValue = "1") Integer displayMall) {
        return Result.ok(couponPackageService.getCouponPackage(displayMall));
    }

    @ApiOperation("根据ID查询券包")
    @ApiResponses({@ApiResponse(code = 200, message = "SUCCESS", response = CouponPackage.class)})
    @GetMapping("/{id}")
    public Result getCouponPackage(@PathVariable Integer id) {
        return Result.ok(new CouponPackage().selectById(id));
    }
}

